import java.util.*;

interface GeneralStack<T> {
	T push(T item);

	T pop();

	T peek();

	public boolean empty();

	public int size();
}

class ArrayListGeneralStack<T> implements GeneralStack<T> {
	List<T> list = new ArrayList<T>();

	@Override
	public T push(T item) {
		list.add(item);
		return item;
	}

	@Override
	public T pop() {
		if (list.isEmpty())
			return null;

		return list.remove(list.size() - 1);
	}

	@Override
	public T peek() {
		if (list.isEmpty())
			return null;

		return list.get(list.size() - 1);
	}

	@Override
	public boolean empty() {
		return list.isEmpty();
	}

	@Override
	public int size() {
		return list.size();
	}

	public String toString() {
		return list.toString();

	}

}

class Car {
	private int id;
	private String name;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return "Car [id=" + id + ", name=" + name + "]";
	}

}

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		while (!s.equals("quit")) {
			switch (s) {
			case "Integer":
				int sum = 0;
				int m = sc.nextInt();
				int n = sc.nextInt();
				ArrayListGeneralStack<Integer> stack = new ArrayListGeneralStack<Integer>();
				System.out.println("Integer Test");
				for (int i = 0; i < m; i++) {
					int a = sc.nextInt();
					stack.push(a);
					System.out.println("push:" + a);
				}
				for (int i = 0; i < n; i++) {
					System.out.println("pop:" + stack.pop());
				}

				System.out.println(stack.toString());
				while (!stack.empty()) {
					sum += stack.pop();
				}
				System.out.println("sum=" + sum);
				System.out.println(stack.getClass().getInterfaces()[0]);
				s = sc.next();
				break;
			case "Double":
				double sum1 = 0;
				int m1 = sc.nextInt();
				int n1 = sc.nextInt();
				ArrayListGeneralStack<Double> stack1 = new ArrayListGeneralStack<Double>();
				System.out.println("Double Test");
				for (int i = 0; i < m1; i++) {
					double a = sc.nextDouble();
					stack1.push(a);
					System.out.println("push:" + a);
				}
				for (int i = 0; i < n1; i++) {
					System.out.println("pop:" + stack1.pop());
				}
				System.out.println(stack1.toString());
				while (!stack1.empty()) {
					sum1 += stack1.pop();
				}
				System.out.println("sum=" + sum1);
				System.out.println(stack1.getClass().getInterfaces()[0]);
				s = sc.next();
				break;

			case "Car":
				int m2 = sc.nextInt();
				int n2 = sc.nextInt();
				ArrayListGeneralStack<Car> stack2 = new ArrayListGeneralStack<Car>();
				System.out.println("Car Test");

				for (int i = 0; i < m2; i++) {
					Car car = new Car();
					car.setId(sc.nextInt());
					car.setName(sc.next());

					stack2.push(car);
					System.out.println("push:" + car);
				}
				for (int i = 0; i < n2; i++) {
					System.out.println("pop:" + stack2.pop());
				}
				System.out.println(stack2.toString());
				while (!stack2.empty()) {
					System.out.println(stack2.pop().getName());
				}
				System.out.println(stack2.getClass().getInterfaces()[0]);
				s = sc.next();
				break;
			}
		}

	}

}